home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / create1a / frmanim.frm < prev    next >
Text File  |  1999-09-25  |  6KB  |  170 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   2310
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   2400
  9.    Icon            =   "frmAnim.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   154
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   160
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin VB.VScrollBar vscSpeed 
  18.       Height          =   2055
  19.       LargeChange     =   25
  20.       Left            =   2040
  21.       Max             =   -1
  22.       Min             =   -1000
  23.       TabIndex        =   5
  24.       Top             =   120
  25.       Value           =   -1
  26.       Width           =   255
  27.    End
  28.    Begin VB.CommandButton cmdLoopType 
  29.       Caption         =   "Alternate"
  30.       Height          =   255
  31.       Index           =   2
  32.       Left            =   120
  33.       TabIndex        =   4
  34.       Top             =   1920
  35.       Width           =   1815
  36.    End
  37.    Begin VB.CommandButton cmdLoopType 
  38.       Caption         =   "&Reverse"
  39.       Height          =   255
  40.       Index           =   1
  41.       Left            =   120
  42.       TabIndex        =   3
  43.       Top             =   1680
  44.       Width           =   1815
  45.    End
  46.    Begin VB.CommandButton cmdLoopType 
  47.       Caption         =   "&Forward"
  48.       Height          =   255
  49.       Index           =   0
  50.       Left            =   120
  51.       TabIndex        =   2
  52.       Top             =   1440
  53.       Width           =   1815
  54.    End
  55.    Begin VB.Timer tmrTime 
  56.       Left            =   120
  57.       Top             =   120
  58.    End
  59.    Begin VB.PictureBox picAnim 
  60.       BackColor       =   &H00FFFFFF&
  61.       BorderStyle     =   0  'None
  62.       Height          =   1230
  63.       Left            =   120
  64.       ScaleHeight     =   82
  65.       ScaleMode       =   3  'Pixel
  66.       ScaleWidth      =   120
  67.       TabIndex        =   1
  68.       Top             =   120
  69.       Width           =   1800
  70.    End
  71.    Begin VB.PictureBox picBuffer 
  72.       AutoRedraw      =   -1  'True
  73.       AutoSize        =   -1  'True
  74.       BackColor       =   &H00C0C0FF&
  75.       BorderStyle     =   0  'None
  76.       Height          =   1230
  77.       Left            =   120
  78.       Picture         =   "frmAnim.frx":000C
  79.       ScaleHeight     =   82
  80.       ScaleMode       =   3  'Pixel
  81.       ScaleWidth      =   600
  82.       TabIndex        =   0
  83.       Top             =   2280
  84.       Visible         =   0   'False
  85.       Width           =   9000
  86.    End
  87. End
  88. Attribute VB_Name = "Form1"
  89. Attribute VB_GlobalNameSpace = False
  90. Attribute VB_Creatable = False
  91. Attribute VB_PredeclaredId = True
  92. Attribute VB_Exposed = False
  93. '----------------------------------------'
  94. 'Title  : Project AnimLogo
  95. 'Author : Timothy Pew
  96. 'E-mail : lord_kirk@geocities.com
  97. 'Copyright ⌐ 1999
  98. '----------------------------------------'
  99. 'This project demonstrates one way to
  100. 'create an animated logo, such as those
  101. 'seen in Netscape Navigator and Microsoft
  102. 'Internet Explorer.
  103. '----------------------------------------'
  104.  
  105. 'constant values for the direction of animation
  106. Const cFORWARD = 0 'loops to first frame after completing final frame
  107. Const cREVERSE = 1 'loops to final frame after completely first frame
  108. Const cALTERNATE = 2 'reverses the order of animation when it completes the first or last frame
  109.  
  110. 'variables
  111. Dim LoopType As Integer 'type of animation to perform, uses one of the above constants
  112. Dim Cnt As Integer 'counter variable to keep track of current frame
  113. Dim Dir As Integer 'used to increment/decrement the frame count as needed
  114.  
  115. Private Sub cmdLoopType_Click(Index As Integer)
  116.     LoopType = Index 'sets the animation type
  117.     If LoopType = cREVERSE Then
  118.         Cnt = 4 'sets the starting frame
  119.         Dir = -1 'count frames backward
  120.     Else
  121.         Cnt = 0 'sets the starting frame
  122.         Dir = 1 'count frames forward
  123.     End If
  124.     'sets the font of button the corrisponds to the LoopType to bold &
  125.     'unbolds the other buttons
  126.     For x = cmdLoopType.LBound To cmdLoopType.ubound
  127.         If x = LoopType Then
  128.             cmdLoopType(x).FontBold = True
  129.         Else
  130.             cmdLoopType(x).FontBold = False
  131.         End If
  132.     Next x
  133.     picAnim.SetFocus 'this is to keep the buttons from having the &
  134.     'focus square for no reason other than that I think it looks sloppy
  135. End Sub
  136.  
  137. Private Sub Form_Load()
  138.     Show 'avoid an error by making sure that form is displayed
  139.     'set the current loop type to alternate by programmatically clicking
  140.     'the "Alternate" button
  141.     cmdLoopType_Click cALTERNATE
  142.     'set the timer but changing the value of vscSpeed
  143.     'vscSpeed uses negative numbers to make the higher value on top
  144.     vscSpeed.Value = -200
  145. End Sub
  146.  
  147. Private Sub tmrTime_Timer()
  148.     Cnt = Cnt + Dir 'increment/decrement Cnt as needed
  149.     Select Case LoopType
  150.         Case cFORWARD:
  151.             If Cnt > 4 Then Cnt = 0
  152.             Dir = 1 'makes sure that the direction is correct
  153.         Case cREVERSE:
  154.             If Cnt < 0 Then Cnt = 4
  155.             Dir = -1 'makes sure that the direction is correct
  156.         Case cALTERNATE:
  157.             'swaps direction
  158.             If (Cnt = 4) Or (Cnt = 0) Then Dir = -Dir
  159.     End Select
  160.     'draw the new frame
  161.     BitBlt picAnim.hDC, 0, 0, 120, 82, picBuffer.hDC, Cnt * 120, 0, SRCCOPY
  162. End Sub
  163.  
  164. Private Sub vscSpeed_Change()
  165.     'set the timer value to the absolute value of vscSpeed
  166.     tmrTime.Interval = Abs(vscSpeed.Value)
  167.     'set the caption to display the current speed
  168.     Caption = "Speed = " & tmrTime.Interval
  169. End Sub
  170.